#ifndef __APP_LIB_UART_BASE_HPP__
#define __APP_LIB_UART_BASE_HPP__

#ifdef __cplusplus
extern "C" {
#endif

#include "BspUart.h"

#define	APP_LIB_UART_PROTOCOL_HEAD0		    0x12
#define	APP_LIB_UART_PROTOCOL_HEAD1			0x34

#define	UART_RX_BUFF_SIZE					1024
#define	UART_RX_MULT_SIZE					4096

#define APP_LIB_UART_MSG_PATH               "/tmp/systemv-msg-uart"

typedef struct _APP_LIB_UART_MULT_PKG_s_
{
	int size;
	int offset;
	UINT8 buf[UART_RX_MULT_SIZE];
} APP_LIB_UART_MULT_PKG_s;

typedef enum __APP_LIB_MSG_TYPE_e__
{
    APP_LIB_MSG_TYPE_RECV = 1,
    APP_LIB_MSG_TYPE_SEND,
    APP_LIB_MSG_TYPE_SPLITE,
    APP_LIB_MSG_TYPE_PROCESS,

    APP_LIB_MSG_TYPE_MAX,
} APP_LIB_MSG_TYPE_e;

typedef void (*APP_LIB_UART_HANDLE_CB_F)(IN UINT8 *, IN UINT16);

typedef struct _APP_LIB_UART_CFG_s_
{
    BSP_UART_CHANNEL_e        eChannel;
    SINT32                    iFd;
    APP_LIB_UART_HANDLE_CB_F  pfSplitPkgCB;
    APP_LIB_UART_HANDLE_CB_F  pfHandlePkgCB;
    APP_LIB_UART_MULT_PKG_s   stPackage;
} APP_LIB_UART_CFG_s;

extern ULONG AppLibUart_PushPacket(IN SLONG s64Type, IN UINT8 *pucPacket, IN UINT16 usLen);
extern ULONG AppLibUart_PopPacket(IN SLONG s64Type, INOUT UINT8 *pucPacket, IN UINT16 usLen);
extern ULONG AppLibUart_Register(INOUT APP_LIB_UART_CFG_s *pstUartCfg);

#ifdef __cplusplus
}
#endif

#endif
